package com.sky.mapper.admin;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;

import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SetmealMapper {

    @Select("SELECT count(id) FROM dish WHERE category_id = #{id}")
    Long selectAll(Long id);


    Page<SetmealVO> selectPage(SetmealPageQueryDTO setmealPageQueryDTO);


    @AutoFill(OperationType.INSERT)
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Setmeal setmeal);

    @Select("select * from setmeal where id = #{id};")
    Setmeal selectById(Long id);

    void deleteBatch(List<Long> idsKeeps);


    @AutoFill(OperationType.UPDATE)
    @Update("update setmeal set update_time = #{updateTime} , update_user = #{updateUser} ,status = (case when status = 0 then 1 else 0 end) where id = #{id}")
    void status(Setmeal setmeal);



    @AutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);
}
